﻿using System.Security.Claims;

namespace Bookify.Web.Services.Auth
{
    public static class ClaimsPrincipalExtensions
    {
        public static string GetName(this ClaimsPrincipal user)
        {
            if (user != null)
            {
                return user.Claims
                    .FirstOrDefault(c => c.Type == ClaimTypes.Name || c.Type == "name")?.Value;
            }
            else
            {
                return string.Empty;
            }
        }
    }
}
